home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3471 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.4 KB

  1. Path: ohstpy.mps.ohio-state.edu!vancleef
  2. From: vancleef@ohstpy.mps.ohio-state.edu
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Abend caused by "strcmp"
  5. Message-ID: <1996Jan24.034057.8808@ohstpy>
  6. Date: 24 Jan 96 03:40:57 -0500
  7. References: <4e4guc$o1u@tst.hk.super.net>
  8. Organization: The Ohio State University, Department of Physics
  9.  
  10. In article <4e4guc$o1u@tst.hk.super.net>, Judy Wong <jlcwong@hk.super.net> writes:
  11. > I am using Borland C++ v4.0 & v4.5.  My machine is Intel Pentium 100.  
  12. > The program I wrote is a window program.
  13. > In v4.5, when my program executes the statement :
  14. >    "if (strcmp(a, NULL) == 0) ..." where a is declared as
  15. >                                          char *a="name";
  16. > it abends with the following 'Unhandled Exception' error msg. :
  17. >                General Protection Exception
  18. >          BC450RTL(1) 0x41A7:0x61c9 Processor Fault
  19. > I used v4.0 & test the program once again.  The above msg. appeared 
  20. > again.  If the statement is changed into :
  21. >                  "if (strcmp(a, "") == 0) ..."
  22. > the program runs smoothly in either v4.0 & v4.5
  23. > In those days before my upgrade to Pentium, I used Intel 386 & v4.0.
  24. > using "strcmp" comparing with NULL was OK.
  25.  
  26. Luck. NEVER put NULL into strcmp(). NULL is an address of 0, while
  27. "" is the address of a 1 byte string with a '\0' in it. "" is not 0.
  28.  
  29. -Garrett
  30.  
  31.  
  32.  
  33. > Is this hardware problem ? Or any other reasons ?
  34. > Thanks you for you help.
  35. > Regards,
  36. > Samson
  37.